﻿
$(function () {
    ///点击共享
    $('#btn_share').click(function () {
        var path = getQueryString("path");
        path = unescape(path);
        var filename = getQueryString("filename");
        filename = unescape(filename);
        //判断课题组和项目库是否被选中
        var xmkIsSelected = 0;
        var teamIsSelected = 0;
        if ($("#checkbox_xmk").checked = true)
            xmkIsSelected = 1;
        if ($("#checkbox_team").checked = true)
            teamIsSelected = 1;
        var ids = "";
        if (teamIsSelected == 1) {
            ids = getSelections();
        }
        $.ajax({
            url: '../WebServices/ShareFile.ashx',
            type: 'post',
            dataType: 'xml', //这里可以不写，但千万别写text或者html!!! 
            data: { xmkIsSelected: xmkIsSelected, teamIsSelected: teamIsSelected, ids: ids, filepath: path, filename: filename },
            timeout: 2000,
            cache: false,
            error: function (xml) {
                alert('文档共享出错' + xml);
            },
            success: function (xml) {
                alert('文档共享成功');
            }
        });
    });
    ///点击
    $('#dmkDiv').click(function () {
        alert("xml is clickd");  
    });
});
        ///获取选中课题组ID
        function getSelections() {
            var ids="";
            var rows = $('#dg').datagrid('getSelections');
            for (var i = 0; i < rows.length; i++) {
                var row = rows[i];
                ids = ids + row.TEAM_ID.toString() + ";"
            }
            return ids;
        }
        function getQueryString(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]); return null;
        }

